#include <stdio.h>

/*
 * 前一个例子的编译结果
 * 编译前面的两个例子，然后反汇编所得到的文件应该是一样的。
 */

int main()
{
	int a;
	char *p;
	static char s0[] = "xiaozhi";
	static char s1[] = "world";

	if (a > 0)
		p = s0;
	else
		p = s1;
	
	printf("Hello, %s\n", p);

	return 0;
}

#if 0

/*
 * intel
 */
0000000000001149 <main>:
    1149:	f3 0f 1e fa          	endbr64 
    114d:	55                   	push   %rbp
    114e:	48 89 e5             	mov    %rsp,%rbp
    1151:	48 83 ec 10          	sub    $0x10,%rsp		// rsp-=0x10
    1155:	83 7d f4 00          	cmpl   $0x0,-0xc(%rbp)		// (rbp-0xc)-0x0
    1159:	7e 0d                	jle    1168 <main+0x1f>		// <= jump
    115b:	48 8d 05 ae 2e 00 00 	lea    0x2eae(%rip),%rax        # 4010 <s0.2317>	// rax=rip+0x2eae
    1162:	48 89 45 f8          	mov    %rax,-0x8(%rbp)		// (rbp-0x8)=rax
    1166:	eb 0b                	jmp    1173 <main+0x2a>		// jump
    1168:	48 8d 05 a9 2e 00 00 	lea    0x2ea9(%rip),%rax        # 4018 <s1.2318>	// rax=rip+2ea9
    116f:	48 89 45 f8          	mov    %rax,-0x8(%rbp)		// (rbp-0x8)=rax
    1173:	48 8b 45 f8          	mov    -0x8(%rbp),%rax		// rax=(rbp-0x8)
    1177:	48 89 c6             	mov    %rax,%rsi		// rsi=rax
    117a:	48 8d 3d 83 0e 00 00 	lea    0xe83(%rip),%rdi        # 2004 <_IO_stdin_used+0x4>	// rdi=rip+0xe83
    1181:	b8 00 00 00 00       	mov    $0x0,%eax		// eax=0
    1186:	e8 c5 fe ff ff       	callq  1050 <printf@plt>	// printf(rdi, rsi)
    118b:	b8 00 00 00 00       	mov    $0x0,%eax		// eax=0
    1190:	c9                   	leaveq 
    1191:	c3                   	retq   
    1192:	66 2e 0f 1f 84 00 00 	nopw   %cs:0x0(%rax,%rax,1)
    1199:	00 00 00 
    119c:	0f 1f 40 00          	nopl   0x0(%rax)

/*
 * arm
 */
000000000040055c <main>:
  40055c:	a9be7bfd 	stp	x29, x30, [sp, #-32]!
  400560:	910003fd 	mov	x29, sp
  400564:	b94017a0 	ldr	w0, [x29, #20]		// w0=[x29+20]
  400568:	7100001f 	cmp	w0, #0x0		// w0-0x0
  40056c:	540000ad 	b.le	400580 <main+0x24>	// <=  jump
  400570:	b0000080 	adrp	x0, 411000 <__libc_start_main@GLIBC_2.17>
  400574:	9100c000 	add	x0, x0, #0x30		// x0=411030
  400578:	f9000fa0 	str	x0, [x29, #24]		// [x29+24]=x0
  40057c:	14000004 	b	40058c <main+0x30>	// jump
  400580:	b0000080 	adrp	x0, 411000 <__libc_start_main@GLIBC_2.17>
  400584:	9100e000 	add	x0, x0, #0x38		// x0=411038
  400588:	f9000fa0 	str	x0, [x29, #24]		// [x29+24]=x0
  40058c:	90000000 	adrp	x0, 400000 <_init-0x3e8>
  400590:	91196000 	add	x0, x0, #0x658		// x0=r00658
  400594:	f9400fa1 	ldr	x1, [x29, #24]		// x1=[x29+24]
  400598:	97ffffae 	bl	400450 <printf@plt>
  40059c:	52800000 	mov	w0, #0x0                   	// #0
  4005a0:	a8c27bfd 	ldp	x29, x30, [sp], #32
  4005a4:	d65f03c0 	ret

#endif

